package com.explorati.LeetCode345.reversevowelsofastring;

import java.util.ArrayList;
import java.util.List;

/**
 * 345. Reverse Vowels of a String
 * 
 * Input: "hello" Output: "holle"
 * 
 * @author explorati
 *
 */
public class Solution {
	public static String reverseVowels(String s) {
		if (s == null || s.length() == 0)
			return s;
		String vowels = "aeiouAEIOU";
		char[] chars = s.toCharArray();
		int start = 0;
		int end = s.length() - 1;
		while (start < end) {

			while (start < end && !vowels.contains(chars[start] + "")) {
				start++;
			}

			while (start < end && !vowels.contains(chars[end] + "")) {
				end--;
			}

			char temp = chars[start];
			chars[start] = chars[end];
			chars[end] = temp;

			start++;
			end--;
		}
		return new String(chars);
	}

	public static void swap(char[] c, int i, int j) {
		char temp = c[i];
		c[i] = c[j];
		c[j] = temp;
	}

	public static void main(String[] args) {
		String s = "LeetCode";
		String str = reverseVowels(s);
		System.out.println(reverseVowels(s));
	}
}
